/*
 *@description: 家辅首页模块
 *@author: wudandan
 *@date: 2021-01-21 13:36:46
*/
'use strict';

import { catalogServices } from '@/api';
import CatalogTreeInfo from '@/model/catalog-set/catalog-tree';
const mutationTypes = {

},
actionTypes = {
  SET_TREE: 'getTreeAction',
  GET_BOOKS: 'getBooks'
},
gettersTypes = {

},
state = {
  bookId: {}
},
mutations = {

},
actions = {
  // 根据教材编码获取课程、课时目录树信息
  async [actionTypes.SET_TREE] ({ commit, state }, params) {
    const res = await catalogServices.getCatalogTree(params),
     treeData = new CatalogTreeInfo();
    if (res.code === '200') {
      treeData.fromJSON(res);
    }
    return treeData;
  },
  // 根据教材编码获取课程、课时目录树信息
  async [actionTypes.GET_BOOKS] ({ commit, state }) {
    const res = await catalogServices.getUsedCatalog();
    return res;
  }
},
getters = {

};
export default {
  namespaced: true,
  state,
  mutationTypes,
  actionTypes,
  gettersTypes,
  mutations,
  actions,
  getters
};
